from django.urls import path, include
from rest_framework.decorators import renderer_classes
from .views import BugViewSet, AnchorViewSet
from rest_framework import routers
from common.renderer import JSONRenderer

router = routers.SimpleRouter()
router.register(r'anchor', AnchorViewSet)

bug_list = BugViewSet.as_view({
    'get': 'list',
    'post': 'create'
})
bug_detail = BugViewSet.as_view({
    'get': 'retrieve',
    'put': 'update',
    'patch': 'partial_update',
    'delete': 'destroy'
})

bug_assign = BugViewSet.as_view({
    'post': 'assign'
}, renderer_classes=[JSONRenderer])

urlpatterns = [
    path('', include(router.urls)),
    path('bug/', bug_list, name='bug-list'),
    path('bug/<int:pk>/', bug_detail, name='bug-detail'),
    path('assign/', bug_assign)
]
